package com.jifeng.br.pjj.bookreader.controller.api;

import com.jifeng.br.pjj.bookreader.entity.FeedbackEntity;
import com.jifeng.br.pjj.bookreader.service.FeedbackService;
import com.jifeng.br.pjj.bookreader.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author PangJunjie
 * @Date 2023/7/20/020
 */
@RestController
@RequestMapping("/api/feedback")
public class FeedbackApiController {
    @Autowired
    private FeedbackService feedbackService;

    @GetMapping("/page")
    public R page(int page, int limit, int userId) {
        FeedbackEntity feedback = new FeedbackEntity();
        feedback.setUserId(userId);
        return R.data(feedbackService.getPage(page, limit, feedback));
    }

    @PostMapping("/save")
    public R save(@RequestBody FeedbackEntity feedback) {
        feedbackService.save(feedback);
        return R.ok();
    }

    @DeleteMapping("/delete/{id}")
    public R delete(@PathVariable int id) {
        feedbackService.removeById(id);
        return R.ok();
    }
}
